package com.cloudkinto.service.qianyi.vo;

import com.cloudkinto.common.error.ErrorEnum;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Author Administrator
 *
 * @Des
 * @Version
 * @Date 2021/9/30
 */
@Data
public class QianyiResponse<T> implements Serializable {

    /**
     * 响应成功"true"|"false"
     */
    private String success;

    /**
     * 响应消息
     */
    private String message;

    /**
     * 响应结果
     */
    private T data;
    private List<Map> channelList = null;
    private List<Map> warehouseList = null;

    /**
     * 成功
     *
     * @param data
     * @return
     */
    public static <T> QianyiResponse<T> success(T data) {
        QianyiResponse result = new QianyiResponse();
        result.setSuccess("true");
        result.setMessage(ErrorEnum.SUCCESS.getResultMsg());
        result.setData(data);
        return result;
    }


    /**
     * 成功 无返回
     *
     * @return
     */
    public static QianyiResponse success() {
        QianyiResponse result = new QianyiResponse();
        result.setSuccess("true");
        result.setMessage(ErrorEnum.SUCCESS.getResultMsg());
        return result;
    }

    /**
     * 失败
     *
     * @param message
     * @return
     */
    public static QianyiResponse failue(String message) {
        QianyiResponse result = new QianyiResponse();
        result.setSuccess("false");
        result.setMessage(message);
        return result;
    }

    public static QianyiResponse channelSuccess(List<Map> channels) {
        QianyiResponse result = new QianyiResponse();
        result.setSuccess("true");
        result.setChannelList(channels);
        return result;
    }

    public static QianyiResponse warehoseSuccess(List<Map> warehouseList) {
        QianyiResponse result = new QianyiResponse();
        result.setSuccess("true");
        result.setWarehouseList(warehouseList);
        return result;
    }
}

